<?php

set_time_limit(0);
// connect
$m = new MongoClient('mongodb://ftp.giemiebier.nl');
$before = microtime(true);
// select a database
$db = $m->test;

// select a collection (analogous to a relational database's table)
$collection = $db->items;
//for($i=100000;$i<900000;$i++){
//	$document = array( "id" => $i, "author" => "boven 100.000" );
//	$collection->insert($document);
//}
//for ($i = 0; $i < 100000; $i++) {
//    $newdata = array('$set' => array("address" => "1 Smith Lane"));
//    $collection->update(array("id" => $i), $newdata);
//}
//$newdata = array('$push' => array("author"=>"test"));
//$collection->update(array("id"=>50000),array($newdata));
//$document = array( "title" => "Calvin and Hobbes", "author" => "Bill Watterson" );
//$collection->insert($document);
// add another record, with a different "shape"
//$document = array( "title" => "XKCD", "online" => true );
//$collection->insert($document);
// find everything in the collection
$cursor = $collection->find(["id" => 899000]);

// iterate through the results
//$count = 0;   
foreach ($cursor as $document) {
    echo json_encode($document) . "<br>";
//    echo $document["id"] . "<br>";
//	echo $document["author"] . "<br>";
}
//echo $count;
echo "done<br>";
$after = microtime(true);
echo ($after - $before) . " sec";
?>